<?php

declare (strict_types=1);

namespace app\beautiful\model;

use app\beautiful\model\appointment\TechnicianModel;
use app\common\model\CommonModel;



class StaffModel extends CommonModel{

    protected  $table_splice = false;

    protected  $name = 'beautiful_shop_staff';

    protected  $pk   = 'staff_id';



    protected $type=[

        'add_value_jurisdiction'=>'array'

    ];



    public function getJurisdictionAttr($value,$data)

    {

        $return='';

        $jurisdiction=[

            1=>'办理会员',

            2=>'余额充值',

            3=>'积分充值',

            4=>'送券',

            5=>'订单管理',

            6=>'囤货订单',

            7=>'代客下单',

            8=>'线下余额补单',

            9=>'相册管理',

            10=>'办理次卡',

            11=> '预约管理', //这个是普通比如门店店长或者核销员的权限

            12=> '我的预约', //技师能看到自己的被预约的

            13=> '技师我的排班',

            14=> '业绩填单',

        ];

//        if($data['adviser_jurisdiction']==1){

//            $return.='顾问权限、';

//        }

        if($data['write_off_jurisdiction']==1){

            $return.='核销权限、';

        }

        $add_value_jurisdiction=json_decode($data['add_value_jurisdiction'],true);

        if(!empty($add_value_jurisdiction)){

            $return.='加值权限(';

            foreach ($add_value_jurisdiction as $v){

                $return.=$jurisdiction[$v].',' ?? '';

            }

            $return.=')';

        }

        return $return;

    }

    public function technician()

    {

        return $this->hasMany(TechnicianModel::class,'staff_id','staff_id');

    }
}



